import Https from '@/utils/https'

// 获取目录列表
const getTree = (params) => Https.get('/api/v1/flink/node/getDirNodes', params, { needCode: true })
// 保存目录
const saveDir = (params) => Https.post('/api/v1/flink/node/saveNode', params, { json: false })
// 保存flinkSql
const saveFlinkTaskNode = (params) => Https.post('/api/v1/flink/sql/saveFlinkTaskNode', params, { needCode: true, json: false })
// 移动节点至其他目录
const changeDir = (params) => Https.post('/api/v1/flink/node/changeNodeDir', params, { json: false })
// 获取目录树
const getTrees = (params) => Https.get('/api/v1/flink/node/getDirNodes', params)
// 获取任务脚本
const getSqlTaskScrpit = (params) => Https.get('/api/v1/flink/sql/getSqlTaskScrpit', params, { needCode: true })
// 保存任务脚本
const saveSqlTaskScript = (params) => Https.post('/api/v1/flink/sql/saveSqlTaskScript', params, { needCode: true })
// 开始调试
const startDebug = (params) => Https.post('/api/v1/flink/sql/startDebug', params, { needCode: true, json: false })
// 开始调试
const stopDebug = (params) => Https.post('/api/v1/flink/sql/stopDebug', params, { needCode: true, json: false })
const collectOnlineData = (params) => Https.post('/api/v1/flink/sql/collectOnlineData', params, { needCode: true, json: false })

// 任务详情
const getTaskDetail = (params) => Https.get('/api/v1/flink/sql/getTaskDetail', params, { needCode: true })
// 获取环境参数配置
const getEnvDetail = (params) => Https.get('/api/v1/flink/sql/getEnvDetail', params, { needCode: true })
// 保存环境参数
const saveEnv = (params) => Https.post('/api/v1/flink/sql/saveEnv', params, { needCode: true })
// 获取调度配置
const getScheduleDetail = (params) => Https.get('/api/v1/flink/sql/getScheduleDetail', params, { needCode: true })
// 保存环境参数
const saveSchedule = (params) => Https.post('/api/v1/flink/sql/saveSchedule', params, { needCode: true })
// 语法检查
const checkGrammar = (params) => Https.post('/api/v1/flink/sql/checkGrammar', params, { needCode: true, json: false })
// 发布
const flinkPublish = (params) => Https.post('/api/v1/flink/node/publish', params, { needCode: true, json: false })
// 锁定解锁
const flinkLockNode = (params) => Https.post('/api/v1/flink/node/lockNode', params, { needCode: true, json: false })
// 获取日志
const getLog = (params) => Https.get('/api/v1/flink/sql/getLog', params, { needCode: true })
// 获取日志
const getSqlTaskSourceTables = (params) => Https.get('/api/v1/flink/sql/getSqlTaskSourceTables', params, { needCode: true })
// 回滚版本
const rollbackVersion = (params) => Https.post('/api/v1/flink/sql/rollbackVersion', params, { needCode: true, json: false })
// 源表
const getDatabasesByDsType = (params) => Https.get('/api/v1/flink/sql/getDatabasesByDsType', params, { needCode: true })
const getTopicAndColumns = (params) => Https.get('/api/v1/flink/sql/getTopicAndColumns', params, { needCode: true })
const saveSource = (params) => Https.post('/api/v1/flink/sql/saveSource', params, { needCode: true })
const previewKafkaData = (params) => Https.get('/api/v1/flink/sql/previewKafkaData', params, { needCode: true })
const getSourceDetail = (params) => Https.get('/api/v1/flink/sql/getSourceDetail', params, { needCode: true })
// 结果表
const getTables = (params) => Https.get('/api/v1/flink/sql/getTables', params, { needCode: true })
const getTableFields = (params) => Https.get('/api/v1/flink/sql/getTableFields', params, { needCode: true })
const getHbaseColumnFamilyNames = (params) => Https.get('/api/v1/flink/sql/getHbaseColumnFamilyNames', params, { needCode: true })
const saveSink = (params) => Https.post('/api/v1/flink/sql/saveSink', params, { needCode: true })
const previewData = (params) => Https.get('/api/v1/flink/sql/previewData', params, { needCode: true })
const getSinkDetail = (params) => Https.get('/api/v1/flink/sql/getSinkDetail', params, { needCode: true })
// 维度表
const saveDim = (params) => Https.post('/api/v1/flink/sql/saveDim', params, { needCode: true })
const getDimDetail = (params) => Https.get('/api/v1/flink/sql/getDimDetail', params, { needCode: true })

// 获取所有节点
const getListAll = (params) => Https.get('/api/v1/flink/node/getAllNodes', params, { needCode: true })

export {
  getListAll, collectOnlineData, getDimDetail, saveDim, getSinkDetail, previewData, saveSink, getHbaseColumnFamilyNames, getTableFields, getTables, getSourceDetail, previewKafkaData, saveSource, getTopicAndColumns, getDatabasesByDsType, rollbackVersion, getSqlTaskSourceTables, getLog, stopDebug, startDebug, flinkLockNode, flinkPublish, checkGrammar, saveSchedule, getScheduleDetail, saveEnv, getEnvDetail, getTaskDetail, saveSqlTaskScript, getSqlTaskScrpit, getTrees, getTree, saveDir, saveFlinkTaskNode, changeDir,
}
